package com.jibei.mendo.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.util.Log;

import com.jibei.mendo.R;
import com.jibei.mendo.utils.Constant;
import com.jibei.mendo.utils.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lhl on 2019/8/17.
 */
public class WelcomeActivity extends BaseActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        createAppDir();
    }

    @SuppressLint("CheckResult")
    @Override
    protected void onResume() {
        super.onResume();
        /*if (MendoApplication.mendoService != null) {
            MendoApplication.mendoService.checkRotateKeyStatus();
            MendoApplication.mendoService.checkPressKeyStatus();
        }*/
        startActivity(new Intent(this, MainActivity.class));
    }

    private void createAppDir() {
        List<String> fileList = new ArrayList<>();
        fileList.add(Constant.LIB_DIR);
        fileList.add(Constant.EXCEL_DIR);
        fileList.add(Constant.FIRMWARE_DIR);
        FileUtils.createDirectoryIfNotExist(fileList);
    }

    private boolean existSDCard() {
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    }

    //在SD卡上创建一个文件夹
    public void createSDCardDir() {
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            // 创建一个文件夹对象，赋值为外部存储器的目录
            File sdcardDir = Environment.getExternalStorageDirectory();
            //得到一个路径，内容是sdcard的文件夹路径和名字
            String path = sdcardDir.getPath() + "/lhl";
            File path1 = new File(path);
            if (!path1.exists()) {
                //若不存在，创建目录，可以在应用启动的时候创建
                path1.mkdirs();
                Log.d("lhl", "path ok,path:" + path);
            }
        } else {
            Log.d("lhl", "path false");
        }
    }
}
